<?php
include '../config/mysql.php';




//添加数据
if(!empty($_POST['typec']) && $_POST['typec'] == 'addgoods'){
    unset($_POST['typec']);
    $_POST['image'] = img('image');
    $res = addsql('goods',$_POST);
    if($res){
        success('goodslist.php','添加成功');
    }else{
        error('goodsadd.php','添加失败');
    }
}

//修改 信息
if(!empty($_POST['type']) && $_POST['type'] == 'editgoods'){
    $id = $_POST['id'];
    unset($_POST['id']);
    unset($_POST['type']);
    if(!empty($_FILES['image']['name'])){
        $_POST['image'] = img('image');
    }
    $res = update('goods',$_POST,' where id = '.$id);
    if($res){
        success('goodslist.php','修改成功');
    }else{
        error('goodslist.php','修改失败');
    }

}



//删除数据
if(!empty($_GET['type']) && $_GET['type'] == 'goodsdel'){
    $id = $_GET['id'];
    $res = del('goods',$id);
    if($res){
        success('goodslist.php','删除成功');
    }else{
        error('goodslist.php','删除失败');
    }
}



